﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;

namespace aucn.web.au
{
    public partial class Gallery : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BindImageList();
        }

        private void BindImageList()
        {
            List<Image> imageList = new List<Image>();
            string[] files = Directory.GetFiles(Server.MapPath("~/au/gallery/thumbs"));
            foreach (string fileName in files)
            {
                if (Regex.IsMatch(fileName, @"\.(jpg|jpeg|png)$", RegexOptions.IgnoreCase))
                {
                    char[] sep = { '\\' };
                    string[] fn = fileName.Split(sep);

                    Image tmp = new Image();
                    tmp.ImageUrl = "/au/gallery/thumbs/" + fn[fn.Length - 1];
                    tmp.AlternateText = "/au/gallery/images/" + fn[fn.Length - 1];
                    imageList.Add(tmp);
                }
            }

            Repeater1.DataSource = imageList;
            Repeater1.DataBind();
                
        }

    }
}
